<!-- 确定订单 -->
<template>
	<view class="v-confirm-order">
		<commodity :specMoney="specMoney" :specCont='specCont' :number='goodForm.count' :content="detailInfo">
		</commodity>
		<view class="v-height2"></view>
		<view class="v-padding">
			<!-- <view class="flex-between v-content">
				<text>周期服务</text>
				<view>{{ detailInfo.service_desc ? detailInfo.service_desc : '暂无服务' }}</view>
			</view> -->
			<view class="flex-between v-content" v-if="specCont">
				<text style="width: 140rpx;">规格</text>
				<view class="flex1 flex-end">{{ specCont }}</view>
			</view>
			<view class="flex-between v-content">
				<text style="width: 60rpx;">发票</text>
				<picker mode="selector" @change="bindPickerChange4" :range="invoiceList"
					:range-key="'copywritingContent'">


					<view class="flex">
						<text :style="copywriting?'color:#333333':''">{{copywriting?copywriting:'请选择是否开发票'}}</text>
						<image class="rightImg margin-left_10rpx" src="/static/arrowRight.png" mode=""></image>
					</view>

				</picker>

			</view>
			<view class="flex-between v-content">
				<text style="width: 70rpx;">备注</text>
				<input v-model="goodForm.remark" placeholder="填写备注" placeholder-class="input-class" />
			</view>

		</view>




		<block>
			<view class="v-height2"></view>
			<view class="v-padding">
				<view class="flex-between v-content">
					<text style="width: 180rpx;">联系人电话</text>
					<input type="number" v-model="goodForm.contacts" placeholder="填写联系人电话"
						placeholder-class="input-class" />
				</view>
			</view>
		</block>
		<view class="v-height2" v-if="isShow != true"></view>
		<view class="v-padding">
			<view class="flex-between padding-top_30rpx">
				<view class="font-weight_bold " style="font-size: 34rpx;">
					价格明细
				</view>
				<!-- Number(goodForm.use_integral * (ratio/100)).toFixed(2) -->
				<!-- 分销类型 -->
				<!-- integral_type -->
				<view style="color: #FF4600;" v-if="integral_type==2">

					兑换比例为1/{{ratio/100}}
				</view>

			</view>
			<!-- <view class="flex-between v-content">
				<text style="color: #000000;">最终秒杀价</text>
				<view style="color: #000000;font-size: 32rpx;">
					￥{{ detailInfo.service_price?detailInfo.service_price:0.00 }}</view>
			</view> -->

			<view class="" v-if="activitType==1||activitType==3">
				<view class="flex-between v-content padding-bottom_40rpx border-bottom-ECECEC"
					v-if="(detailInfo.order_integral=='0'||!detailInfo.order_integral)">
					<view class="flex">
						<image class="deductionFeeImg" src="/static/团源码/组合 2957.png" mode="aspectFill"></image>
						<text style="color: #000000;font-size: 32rpx;">抵用金</text>

					</view>
					<view class="flex">
						<radio-group name="apply" @click="handleApplyType" class="flex-align-center">
							<label class="apply-radio flex-align-center">
								<radio :disabled="can_use_integral==1?false:true" style="transform:scale(0.7)"
									value="r1" color="#0095FF" :checked="checked" />

							</label>

						</radio-group>

						<view style="color: #FF4600; font-size: 32rpx;">
							￥{{ Number(goodForm.use_integral).toFixed(2)? Number(goodForm.use_integral).toFixed(2) :'0.00' }}
						</view>



					</view>
				</view>
				<view class="flex-between v-content padding-bottom_40rpx border-bottom-ECECEC" v-else>
					<view class="flex">
						<image class="deductionFeeImg" src="/static/团源码/组合 2957.png" mode="aspectFill"></image>
						<text style="color: #000000;font-size: 32rpx;">抵用金</text>

					</view>
					<view class="flex">


						<view style="color: #FF4600; font-size: 32rpx;">
							-￥{{ Number(detailInfo.order_integral).toFixed(2)? Number(detailInfo.order_integral).toFixed(2) :'0.00' }}
						</view>



					</view>
				</view>
			</view>
			<view class="" v-else>
				<view class="flex-between v-content padding-bottom_40rpx border-bottom-ECECEC">
					<view class="flex">
						<image class="deductionFeeImg" src="/static/团源码/组合 2957.png" mode="aspectFill"></image>
						<text style="color: #000000;font-size: 32rpx;">抵用金</text>

					</view>
					<view class="flex">
						<radio-group name="apply" @click="handleApplyType" class="flex-align-center">
							<label class="apply-radio flex-align-center">
								<radio :disabled="can_use_integral==1?false:true" style="transform:scale(0.7)"
									value="r1" color="#0095FF" :checked="checked" />

							</label>

						</radio-group>

						<view style="color: #FF4600; font-size: 32rpx;">
							￥{{ Number(goodForm.use_integral).toFixed(2)? Number(goodForm.use_integral).toFixed(2) :'0.00' }}
						</view>



					</view>
				</view>
			</view>
			<view class="flex-between v-content padding-bottom_40rpx border-bottom-ECECEC" v-if="activitType==1">
				<view class="flex">
					<image class="deductionFeeImg" src="/static/组合 3046.png" mode="aspectFill"></image>
					<text style="color: #000000;font-size: 32rpx;">报名费</text>

				</view>
				<view class="flex">
					<view style="color: #FF4600; font-size: 32rpx;">
						-￥{{ detailInfo.entry_fee}}
					</view>




				</view>
			</view>

			<view class="flex-between v-content font-weight_bold" v-if="userInfosObj.is_partner==0">
				<text style="color: #000000;font-size: 32rpx;">实际付款</text>
				<view style="color: #000000;font-size: 32rpx;" v-if="activitType==1&&detailInfo.order_status==1">
					<!-- detailInfo.order_integral?detailInfo.order_integral:0 -->
					<!-- -parseFloat(detailInfo.entry_fee?detailInfo.entry_fee:0) -->
					￥{{ Number(((Number(finalPrice((specMoney*Number(goodForm.count)),goodForm.use_integral)).toFixed(2)?Number(finalPrice((specMoney *Number(goodForm.count)),checked?integral_type==2?Number(specMoney * (ratio/100)).toFixed(2):goodForm.use_integral:0)).toFixed(2):'0.00' ))).toFixed(2)}}
				</view>
				<!-- detailInfo.order_integral?detailInfo.order_integral:0 -->
				<view style="color: #000000;font-size: 32rpx;" v-else-if="detailInfo.order_status==1">
					￥{{ Number(((Number(finalPrice((specMoney*Number(goodForm.count)),goodForm.use_integral)).toFixed(2)?Number(finalPrice((specMoney *Number(goodForm.count)),checked?integral_type==2?Number(specMoney * (ratio/100)).toFixed(2):goodForm.use_integral:0)).toFixed(2):'0.00' ))).toFixed(2)}}
				</view>
				<view style="color: #000000;font-size: 32rpx;" v-else>
					￥{{ Number(((Number(finalPrice((specMoney*Number(goodForm.count)),goodForm.use_integral)).toFixed(2)?Number(finalPrice((specMoney *Number(goodForm.count)),checked?integral_type==2?Number(specMoney * (ratio/100)).toFixed(2):goodForm.use_integral:0)).toFixed(2):'0.00' ))).toFixed(2)}}
				</view>
				<!-- <view style="color: #000000;font-size: 32rpx;">
						￥{{Number(finalPrice(3000.68,368.83)).toFixed(2) }}</view> -->
			</view>



			<view class="flex-between v-content font-weight_bold" v-if="userInfosObj.is_partner==1">
				<text style="color: #000000;font-size: 32rpx;">实际付款</text>
				<view style="color: #000000;font-size: 32rpx;" v-if="activitType==1&&detailInfo.order_status==1">
					<!-- detailInfo.order_integral?detailInfo.order_integral:0 -->
					<!-- -parseFloat(detailInfo.entry_fee?detailInfo.entry_fee:0) -->
					￥{{ Number(((Number(finalPrice((specMoney*Number(goodForm.count)),goodForm.use_integral)).toFixed(2)?Number(finalPrice((specMoney *Number(goodForm.count)),checked?integral_type==2?Number(specMoney * (ratio/100)).toFixed(2):goodForm.use_integral:0)).toFixed(2):'0.00' ))).toFixed(2)}}
				</view>
				<!-- detailInfo.order_integral?detailInfo.order_integral:0 -->
				<view style="color: #000000;font-size: 32rpx;" v-else-if="detailInfo.order_status==1">
					￥{{ Number(((Number(finalPrice((specMoney*Number(goodForm.count)),goodForm.use_integral)).toFixed(2)?Number(finalPrice((specMoney *Number(goodForm.count)),checked?integral_type==2?Number(specMoney * (ratio/100)).toFixed(2):goodForm.use_integral:0)).toFixed(2):'0.00' ))).toFixed(2)}}
				</view>
				<view style="color: #000000;font-size: 32rpx;" v-else>
					￥{{ Number(((Number(finalPrice((specMoney*Number(goodForm.count)),goodForm.use_integral)).toFixed(2)?Number(finalPrice((specMoney *Number(goodForm.count)),checked?integral_type==2?Number(specMoney * (ratio/100)).toFixed(2):goodForm.use_integral:0)).toFixed(2):'0.00' ))).toFixed(2)}}
				</view>
				<!-- <view style="color: #000000;font-size: 32rpx;">
						￥{{Number(finalPrice(3000.68,368.83)).toFixed(2) }}</view> -->
			</view>
		</view>
		<view style="height: 400rpx;"></view>
		<view class="fixed bjfff ">
			<view class="" style="padding: 40rpx 20rpx 0;" v-if="isShow != true">
				<view class="flex-between v-content">
					<view class="flex">
						<image style="width: 40.02rpx;height: 40rpx;margin-top: 10rpx;" src="/static/团源码/组合 2956.png"
							mode="aspectFit"></image>

						<text style="margin-left: 15rpx;">微信支付</text>
					</view>
					<radio-group name="apply" class="flex-align-center">
						<label class="apply-radio flex-align-center">
							<radio style="transform:scale(0.7)" value="1" color="#0095FF" checked />

						</label>

					</radio-group>
				</view>
			</view>
			<!-- 隐私协议 -->
			<radio-group name="apply" class="radioText flex" :class="'animation-' + animation" @click="checkedOn2()">
				<label @click.stop="checkedOn2()">
					<radio :checked="agreeChecked" value="1" color="#1890ff"
						style="transform:scale(0.8);padding-left:12rpx;" />
				</label>
				<view class="agree flex-align-center">
					<view>我已阅读并同意</view>
					<text @click.stop="toAgreement()">《{{protocolInfo.protocol_name}}》</text>
				</view>
			</radio-group>
			<!-- has_buy（bool类型字段 ）：true 已买 ,false 没买 -->
			<!-- 已买则用尾款金额——优惠券 否则是报名费 -->
			<!-- -parseFloat((current_money==detailInfo.order_money)?detailInfo.entry_fee?detailInfo.entry_fee:0:0) -->
			<view class="purchaseGoods flex" @click="payTo()">
				<view class="" style="color: #fff;" v-if="activitType==1&&detailInfo.order_status==1">
					立即支付
					￥{{ Number(((Number(finalPrice((specMoney*Number(goodForm.count)),goodForm.use_integral)).toFixed(2)?Number(finalPrice((specMoney *Number(goodForm.count)),checked?integral_type==2?Number(specMoney * (ratio/100)).toFixed(2):goodForm.use_integral:0)).toFixed(2):'0.00' ))).toFixed(2)}}
				</view>
				<view class="" style="color: #fff;" v-else-if="detailInfo.order_status==1">
					立即支付
					￥{{ Number(((Number(finalPrice((specMoney*Number(goodForm.count)),goodForm.use_integral)).toFixed(2)?Number(finalPrice((specMoney *Number(goodForm.count)),checked?integral_type==2?Number(specMoney * (ratio/100)).toFixed(2):goodForm.use_integral:0)).toFixed(2):'0.00' ))).toFixed(2)}}

				</view>
				<view class="" style="color: #fff;" v-else>
					立即支付

					￥{{ Number(((Number(finalPrice((specMoney*Number(goodForm.count)),goodForm.use_integral)).toFixed(2)?Number(finalPrice((specMoney *Number(goodForm.count)),checked?integral_type==2?Number(specMoney * (ratio/100)).toFixed(2):goodForm.use_integral:0)).toFixed(2):'0.00' ))).toFixed(2)}}
				</view>




			</view>
		</view>
		<!-- 使用优惠券 -->
		<sunui-popup ref="popcoupon">
			<template v-slot:content>
				<view class="v-pop-coupon">
					<view class="v-coupon-tilte flex">优惠明细</view>
					<mescroll-body ref="mescrollRef" @init="mescrollInit" :down="downOption" @down="downCallback"
						@up="upCallback">
						<scroll-view scroll-y :style="list && Number(list.length) > 0 ? 'height:524rpx;' : ''">
							<block v-for="(item, index) in list" :key="index">
								<view class="flex-between v-coupons">
									<view class="flex-align-center v-left">
										<view class="flex-column">
											<view class="v-coupon-price">￥{{ item.less_money }}</view>
											<view class="v-identification" v-if="item.coupon_type == 2">无门槛</view>
										</view>
										<view class="flex-columns v-conditions-met flex1">
											<view class="v-bold">
												{{ item.coupon_type == 1 ? '满' + item.meet_money + '可用' : item.name }}
											</view>
											<text>有效期至 {{ item.expiration_time }}</text>
										</view>
									</view>
									<radio-group name="apply">
										<label class="flex-align-center">
											<radio :value="item.value" color="#494949" :checked="item.checkCoupon"
												style="padding:12rpx;" @click="checkeBox(item.id, item)" />
										</label>
									</radio-group>
								</view>
							</block>
						</scroll-view>
					</mescroll-body>
				</view>
			</template>
		</sunui-popup>
	</view>
</template>

<script>
	import antiThrottling from '@/utils/antiThrottling.js';
	export default {
		data() {
			return {
				copywriting: '',
				// (0:无需开票,1:需要开票)
				invoiceList: [{
					id: 0,
					copywritingContent: '无需开票'
				}, {
					id: 1,
					copywritingContent: '需要开票'
				}],
				// 普通商品下单提交
				goodForm: {
					// 联系人
					contacts: '',

					// 备注
					remark: '',
					// 商品id
					goods_id: '',
					// 规格商品id
					spec_id: '',
					// 团购商品id
					order_id: '',
					// 秒杀商品id
					seckill_id: '',
					// 砍价id
					bargains_id: '',
					// 众筹
					presell_id: '',
					// 抵扣金
					use_integral: uni.getStorageSync('user').integral ? uni.getStorageSync('user').integral : 0,
					// 是否开发票
					need_invoice: '',
					// 数量
					count: 1,
					// uid
					uid: uni.getStorageSync('uid')


				},


				// 优惠券选择
				checkCoupon: false,

				mobile: uni.getStorageSync('mobile'),
				cc: 0,
				time: '',
				// 优惠券列表
				list: [],
				// 优惠id
				couponId: '',
				// 优惠金额
				couponMoney: '',
				// 优惠语
				couponHint: '',

				// 实际付款
				realSum: 0,
				userInfosObj: {},

				user: uni.getStorageSync('user'),

				// 填写真实姓名（非必传）
				contacts: '',
				integralChecked: false,
				// 积分兑换比例 多少积分兑换一元
				ratio: '',
				// 抵用金抵扣类型 1-固定值 2-比例值
				integral_type: '',
				// 当前是否可以使用抵扣金  1.可以 2 不可以
				can_use_integral: 1,

				// 默认选中微信支付
				applyType: 1,
				detailInfo: {},
				// true：为“团购商品”详情页 flase:为“普通商品”详情页
				isGroupShop: false,
				lists: [],

				// 实付款
				realPayment: 0,
				// 生成订单返回——order_number和order_id
				itemAll: {},
				// 商品分享海报传入的分享uid
				pid: '',
				specMoney: 0,
				specCont: '',
				moneyItem: {},


				protocolInfo: {}, //协议对象
				checked: false,

				agreeChecked: false, //隐私协议 单选框
				animation: '', // 动画样式
				isBalance: false, //判断余额支付是否点击
				activitType: '',
				payPrice: ''
			};
		},
		onLoad(options) {
			this.userInfos()
			var pages = getCurrentPages(); //当前页
			var beforePage = pages[pages.length - 2]; //上个页面
			this.detailInfo = beforePage.$vm.detailInfo;
			this.activitType = beforePage.$vm.activitType
			// 抵扣百分比




			// 当前是否可以使用抵扣金  1.可以 2 不可以 
			this.can_use_integral = this.detailInfo.can_use_integral
			if (beforePage.$vm.activitType == 0) {
				this.goodForm.count = beforePage.$vm.numberBox;

				this.goodForm.goods_id = beforePage.$vm.detailInfo.id;
				// 

				if (beforePage.$vm.moneyItem) {
					console.log(beforePage.$vm.moneyItem)
					this.moneyItem = beforePage.$vm.moneyItem;
					this.specMoney = beforePage.$vm.moneyItem.money ? beforePage.$vm.moneyItem.money : beforePage.$vm
						.detailInfo.money;
					this.specCont = beforePage.$vm.moneyItem.name;
					this.goodForm.spec_id = beforePage.$vm.moneyItem.id;
				}
			} else if (beforePage.$vm.activitType == 1) {
				this.specMoney = beforePage.$vm.detailInfo.order_money;
				this.specCont = beforePage.$vm.detailInfo.spec_name;
				this.current_money = beforePage.$vm.detailInfo.current_money;
				this.goodForm.order_id = beforePage.$vm.detailInfo.id;
			} else if (beforePage.$vm.activitType == 2) {
				this.specMoney = beforePage.$vm.detailInfo.money;
				this.specCont = beforePage.$vm.detailInfo.spec_name;
				this.goodForm.seckill_id = beforePage.$vm.detailInfo.id;
			} else if (beforePage.$vm.activitType == 3) {
				console.log(beforePage.$vm.detailInfo.order_money, '=====================================')
				this.specMoney = beforePage.$vm.detailInfo.order_money;
				this.specCont = beforePage.$vm.detailInfo.spec_name;
				this.goodForm.bargains_id = beforePage.$vm.detailInfo.id;
			} else if (beforePage.$vm.activitType == 4) {
				this.specMoney = beforePage.$vm.detailInfo.money;
				this.specCont = beforePage.$vm.detailInfo.spec_name;
				this.goodForm.presell_id = beforePage.$vm.detailInfo.id;
			}





			this.getProtocol();
		},
		onShow() {
			if (this.isShow == true || this.detailInfo.is_zero_pay == 2) {
				this.detailInfo.entry_price = 0; //报名费置零
			}
			antiThrottling.releaseKey('submit');
		},
		computed: {
			finalPrice: function() {

				return function(price, couponPrice) {
					let result
					if (this.userInfosObj.is_partner == 0) {
						if (this.integral_type == 1) {


							result = price - (parseFloat(couponPrice) > parseFloat(this.detailInfo.use_integral) ?
								this
								.detailInfo.use_integral : couponPrice)

						} else {

							// 这里还要判断当前积分是多少
							result = price - (this.checked ? ((Number(couponPrice) > Number(this.goodForm
									.use_integral)) ? Number(this.goodForm.use_integral) : Number(
									couponPrice)) :
								couponPrice);


						}
					} else {
						if (this.integral_type == 1) {


							result = price - (parseFloat(couponPrice) > parseFloat(this.detailInfo
									.use_integral_partner) ? this
								.detailInfo.use_integral_partner : couponPrice)

						} else {

							// 这里还要判断当前积分是多少
							result = price - (this.checked ? ((Number(couponPrice) > Number(this.goodForm
									.use_integral)) ? Number(this.goodForm.use_integral) : Number(
									couponPrice)) :
								couponPrice);


						}
					}



					// console.log(result, 'finalPrice')

					// 防止出行负数
					if (result <= 0) {

						return Math.max(0.01, result.toFixed(2));

					} else {
						return result.toFixed(2);
					}
				};


			},

			finalPriceNegative: function() {
				return function(price, couponPrice) {
					let result = price - couponPrice;
					console.log(result, couponPrice)
					// 防止出行负数
					if (result < 0) {
						// return Math.max(0.01, result.toFixed(2));
						console.log(price, 'finalPriceNegative')
						
						
						return Math.abs(price);
					} else {
						return ((Number(couponPrice) > Number(this.goodForm
								.use_integral)) ? Number(this.goodForm.use_integral) : Number(
								couponPrice)).toFixed(2) 
						
						
						// return Number(couponPrice).toFixed(2);
					}
				};


			},

		},
		methods: {
			async userInfos() {
				const result = await this.$http.get({
					url: this.$api.userInfo,
					data: {
						// 用户id
						uid: uni.getStorageSync('uid'),
						// 上级id
						pid: '',

					}
				});
				if (result.errno == 0) {
					this.userInfosObj = result.data

					this.ratio = this.userInfosObj.is_partner == 0 ? this.detailInfo.use_integral : this.detailInfo
						.use_integral_partner
					uni.setStorageSync('user', result.data);

					// 抵用金抵扣类型 1-固定值 2-比例值
					this.integral_type = this.userInfosObj.is_partner == 0 ? this.detailInfo.integral_type : this
						.detailInfo.integral_type_partner

				}
			},
			bindPickerChange4(e) {
				console.log(e, this.copywritingList)
				this.goodForm.need_invoice = this.invoiceList[e.detail.value].id;
				this.copywriting = this.invoiceList[e.detail.value].copywritingContent //POI地址名称
			},
			// 去查看隐私协议
			toAgreement() {
				console.log('去查看隐私协议');
				this.$sun.navGo('/pages/confirmOrder/service-declaration');
			},
			//单选 选择框
			checkedOn2() {
				// 将this.agreeChecked==true 做条件判断，且赋值给agreeChecked。
				this.agreeChecked = this.agreeChecked == true ? false : true;
			},
			//单选框{（支付方式）
			handleApplyType() {
				console.log('测试')
				if (this.can_use_integral == 1) {
					this.checked = this.checked == true ? false : true;
				}

			},

			// 商城设置_协议
			async getProtocol() {
				const result = await this.$http.get({
					url: this.$api.mallSet,
					data: {}
				});
				if (result.errno == 0) {
					this.protocolInfo = result.data;
					console.log('商城设置_协议', result.data);
				} else {
					this.$sun.toast(result.message);
				}
			},

			// “使用优惠券”弹框
			couponClick() {
				this.$refs.popcoupon.show({
					anim: 'bottom',
					position: 'bottom',
					shadeClose: true, //false使用户不能点击其它关闭页面
					topclose: false
				});
			},
			// 我的优惠券
			async upCallback(scroll) {

			},
			//优惠卷单选框
			checkeBox(id, item) {

			},




			couponClose() {
				this.$refs.popcoupon.close();
			},
			// 立即支付
			payTo() {
				// this.$sun.navRe('/pages/orderMessage/orderList/orderList', {
				// 	tabSwitchOrder: 2,
				// 	tabOrder: 4
				// });


				// // 团购报名+尾款为负数，则提示（修改！！）
				if (!this.agreeChecked) {
					this.$sun.toast('请先阅读并同意《平台交易规则》');
					this.animation = 'shake';
					setTimeout(() => {
						this.animation = '';
					}, 1300);
					return;
				} else {
					this.hintClick();
				}
			},
			hintClick() {
				antiThrottling.uniDoFunc({
					// 键名
					key: 'submit',
					success: async () => {
						//锁定
						antiThrottling.lockKey('submit');
						// 报名支付/团购支付/普通商品支付
						// true：为“团购商品”详情页 flase:为“普通商品”详情页
						if (this.activitType == 0) {

							if (typeof this.goodForm.need_invoice === 'string' && this.goodForm
								.need_invoice === "") {
								this.$sun.toast('请填写是否需要开发票', 'none')
								antiThrottling.releaseKey('submit');
							} else if (!(/^1[3456789]\d{9}$/.test(this.goodForm.contacts))) {
								this.$sun.toast('请填写正确联系人电话', 'none')
								antiThrottling.releaseKey('submit');
							} else {
								// antiThrottling.releaseKey('submit');
								// 普通订单
								this.addOrders();
							}


						} else if (this.activitType == 1) {
							/* order_obj 有值，且status 状态 ==1 代表有待支付订单，则不允许再次报名
								否则直接拿order_id 进行结算下单 */
							// 是否已经报名
							if (typeof this.goodForm.need_invoice === 'string' && this.goodForm
								.need_invoice === "") {
								this.$sun.toast('请填写是否需要开发票', 'none')
								antiThrottling.releaseKey('submit');
							} else if (!(/^1[3456789]\d{9}$/.test(this.goodForm.contacts))) {
								this.$sun.toast('请填写正确联系人电话', 'none')
								antiThrottling.releaseKey('submit');
							} else {
								if (this.detailInfo.is_apply) {
									// 支付团购余款
									this.groupPayOrder();
								}
							}


						} else if (this.activitType == 2) {

							if (typeof this.goodForm.need_invoice === 'string' && this.goodForm
								.need_invoice === "") {
								this.$sun.toast('请填写是否需要开发票', 'none')
								antiThrottling.releaseKey('submit');
							} else if (!(/^1[3456789]\d{9}$/.test(this.goodForm.contacts))) {
								this.$sun.toast('请填写正确联系人电话', 'none')
								antiThrottling.releaseKey('submit');
							} else {
								this.seckillPayOrder()
							}



						} else if (this.activitType == 3) {

							if (typeof this.goodForm.need_invoice === 'string' && this.goodForm
								.need_invoice === "") {
								this.$sun.toast('请填写是否需要开发票', 'none')
								antiThrottling.releaseKey('submit');
							} else if (!(/^1[3456789]\d{9}$/.test(this.goodForm.contacts))) {
								this.$sun.toast('请填写正确联系人电话', 'none')
								antiThrottling.releaseKey('submit');
							} else {
								this.bargainsPayOrder()
							}



						} else if (this.activitType == 4) {

							if (typeof this.goodForm.need_invoice === 'string' && this.goodForm
								.need_invoice === "") {
								this.$sun.toast('请填写是否需要开发票', 'none')
								antiThrottling.releaseKey('submit');
							} else if (!(/^1[3456789]\d{9}$/.test(this.goodForm.contacts))) {
								this.$sun.toast('请填写正确联系人电话', 'none')
								antiThrottling.releaseKey('submit');
							} else {
								this.presellPayOrder()
							}



						}
					}
				});
			},
			// 砍价支付
			async bargainsPayOrder() {
				// (Number(this.specMoney) + Number(this.detailInfo	.order_integral ? this.detailInfo.order_integral : 0))
				let use_integral

				if (this.userInfosObj.is_partner == 0) {
					if (this.detailInfo.order_status == 1) {
						// 计算积分实付款
						use_integral = Number(this.finalPriceNegative(((Number(this.specMoney) + Number(0)) * Number(
								this
								.goodForm
								.count)),
							this
							.checked ? this.integral_type == 1 ? (parseFloat(this.goodForm.use_integral) <
								parseFloat(
									this.detailInfo.use_integral) ? this.goodForm.use_integral : this
								.detailInfo
								.use_integral) : Number(Math.round((Number(this.specMoney) + Number(0)) * this
								.ratio) / 100)
							.toFixed(2) :
							0
						)).toFixed(2)
					} else {
						// 计算积分实付款
						use_integral = Number(this.finalPriceNegative(((Number(this.specMoney) + Number(0)) * Number(
								this
								.goodForm
								.count)),
							this
							.checked ? this.integral_type == 1 ? (parseFloat(this.goodForm.use_integral) <
								parseFloat(
									this.detailInfo.use_integral) ? this.goodForm.use_integral : this
								.detailInfo
								.use_integral) : Number(Math.round((Number(this.specMoney) + Number(0)) * this
								.ratio) / 100)
							.toFixed(2) :
							0
						)).toFixed(2)
					}

				} else {
					if (this.detailInfo.order_status == 1) {
						// 计算积分实付款
						use_integral = Number(this.finalPriceNegative(((Number(this.specMoney) + Number(0)) * Number(
								this
								.goodForm
								.count)),
							this
							.checked ? this.integral_type == 1 ? (parseFloat(this.goodForm
									.use_integral) <
								parseFloat(
									this.detailInfo.use_integral_partner) ? this.goodForm.use_integral : this
								.detailInfo
								.use_integral_partner) : Number(Math.round((Number(this.specMoney) + Number(
									0)) * this
								.ratio) / 100)
							.toFixed(2) :
							0
						)).toFixed(2)
					} else {
						// 计算积分实付款
						use_integral = Number(this.finalPriceNegative(((Number(this.specMoney) + Number(0)) * Number(
								this
								.goodForm
								.count)),
							this
							.checked ? this.integral_type == 1 ? (parseFloat(this.goodForm
									.use_integral) <
								parseFloat(
									this.detailInfo.use_integral_partner) ? this.goodForm.use_integral : this
								.detailInfo
								.use_integral_partner) : Number(Math.round((Number(this.specMoney) + Number(
									0)) * this
								.ratio) / 100)
							.toFixed(2) :
							0
						)).toFixed(2)
					}

				}

				console.log(this.checked ? use_integral : '')
				const {
					order_id,
					presell_id,
					...newGoodForm
				} = this.goodForm;


				if (this.userInfosObj.is_partner == 0) {
					if (this.detailInfo.order_status == 1) {
						this.payPrice = Number(this.finalPrice(((Number(this.specMoney) + Number(0)) * Number(this
								.goodForm
								.count)), this.goodForm
							.use_integral)).toFixed(2) ? Number(this.finalPrice(((Number(this.specMoney) + Number(
								0)) *
							Number(this
								.goodForm
								.count)), this.checked ? this.integral_type == 2 ? Number((Number(this
									.specMoney) +
								Number(0)) *
							(this.ratio / 100)).toFixed(2) : this.goodForm.use_integral : 0)).toFixed(2) : '0.00'


					} else {
						this.payPrice = Number(this.finalPrice((this.specMoney * Number(this.goodForm.count)), this
							.goodForm
							.use_integral)).toFixed(2) ? Number(this.finalPrice((this.specMoney * Number(this
							.goodForm
							.count)), this.checked ? this.integral_type == 2 ? Number(this.specMoney *
							(this.ratio / 100)).toFixed(2) : this.goodForm.use_integral : 0)).toFixed(2) : '0.00'

					}
				} else {
					if (this.detailInfo.order_status == 1) {
						this.payPrice = Number(this.finalPrice(((Number(this.specMoney) + Number(0)) * Number(this
								.goodForm
								.count)), this.goodForm
							.use_integral)).toFixed(2) ? Number(this.finalPrice(((Number(this.specMoney) + Number(
								0)) *
							Number(this
								.goodForm
								.count)), this.checked ? this.integral_type == 2 ? Number((Number(
									this
									.specMoney) +
								Number(0)) *
							(this.ratio / 100)).toFixed(2) : this.goodForm.use_integral : 0)).toFixed(2) : '0.00'


					} else {
						this.payPrice = Number(this.finalPrice((this.specMoney * Number(this.goodForm.count)), this
							.goodForm
							.use_integral)).toFixed(2) ? Number(this.finalPrice((this.specMoney * Number(this
							.goodForm
							.count)), this.checked ? this.integral_type == 2 ? Number(this
							.specMoney *
							(this.ratio / 100)).toFixed(2) : this.goodForm.use_integral : 0)).toFixed(2) : '0.00'

					}
				}


				console.log(newGoodForm, (this.payPrice), this.checked ? Number(use_integral) : this.detailInfo
					.order_status == 1 ?
					(this.detailInfo.order_integral ? this.detailInfo.order_integral : '0') : '0')

				const result = await this.$http.post({
					url: this.$api.bargainsBuy,
					data: {

						use_integral: this.checked ? Number(use_integral) : this.detailInfo.order_status == 1 ?
							(this.detailInfo.order_integral ? this.detailInfo.order_integral : '0') : '0',
						order_id: this.detailInfo.order_id,

						uid: uni.getStorageSync('uid'),
						// 产品id
						// presell_id: this.detailInfo.id,


						// 备注
						remark: newGoodForm.remark,

						// 是否需要开发票 1.不需要 2 需要
						need_invoice: newGoodForm.need_invoice,
						// 联系人
						contacts: newGoodForm.contacts,

					}
				});
				if (result.errno == 0) {
					this.itemAll = result.data;
					console.log(this.itemAll)

					this.applyOrder(this.itemAll);
				} else {
					this.$sun.toast(result.message);
					antiThrottling.releaseKey('submit');
				}
			},
			// 众筹
			async presellPayOrder() {
				let use_integral
				if (this.userInfosObj.is_partner == 0) {
					use_integral = Number(this.finalPriceNegative((this.specMoney * Number(this.goodForm.count)),
						this
						.checked ? this.integral_type == 1 ? (parseFloat(this.goodForm.use_integral) <
							parseFloat(
								this.detailInfo.use_integral) ? this.goodForm.use_integral : this.detailInfo
							.use_integral) : Number(Math.round(this.specMoney * this.ratio) / 100).toFixed(2) :
						0
					)).toFixed(2)
				} else {
					use_integral = Number(this.finalPriceNegative((this.specMoney * Number(this.goodForm.count)),
						this
						.checked ? this.integral_type == 1 ? (parseFloat(this.goodForm.use_integral) <
							parseFloat(
								this.detailInfo.use_integral_partner) ? this.goodForm.use_integral : this
							.detailInfo
							.use_integral_partner) : Number(Math.round(this.specMoney * this.ratio) / 100)
						.toFixed(2) :
						0
					)).toFixed(2)
				}




				console.log(this.checked ? use_integral : '')
				const {
					order_id,
					presell_id,
					...newGoodForm
				} = this.goodForm;
				if (this.userInfosObj.is_partner == 0) {
					this.payPrice = Number(this.finalPrice((this.specMoney * Number(this.goodForm.count)), this
						.goodForm
						.use_integral)).toFixed(2) ? Number(this.finalPrice((this.specMoney * Number(this.goodForm
						.count)), this.checked ? this.integral_type == 2 ? Number(this.specMoney *
						(this.ratio / 100)).toFixed(2) : this.goodForm.use_integral : 0)).toFixed(2) : '0.00'
				} else {
					this.payPrice = Number(this.finalPrice((this.specMoney * Number(this.goodForm.count)), this
						.goodForm
						.use_integral)).toFixed(2) ? Number(this.finalPrice((this.specMoney * Number(this.goodForm
						.count)), this.checked ? this.integral_type == 2 ? Number(this.specMoney *
						(this.ratio / 100)).toFixed(2) : this.goodForm.use_integral : 0)).toFixed(2) : '0.00'
				}


				console.log(newGoodForm, (this.payPrice), use_integral)



				const result = await this.$http.post({
					url: this.$api.presellPresellPay,
					data: {

						use_integral: this.checked ? Number(use_integral) : '0',


						uid: uni.getStorageSync('uid'),
						// 产品id
						presell_id: this.detailInfo.id,


						// 备注
						remark: newGoodForm.remark,

						// 是否需要开发票 1.不需要 2 需要
						need_invoice: newGoodForm.need_invoice,
						// 联系人
						contacts: newGoodForm.contacts,

					}
				});
				if (result.errno == 0) {
					this.itemAll = result.data;
					console.log(this.itemAll)

					this.applyOrder(this.itemAll);
				} else {
					this.$sun.toast(result.message);
					antiThrottling.releaseKey('submit');
				}
			},
			// 秒杀付款
			async seckillPayOrder() {
				let use_integral
				if (this.userInfosObj.is_partner == 0) {
					use_integral = Number(this.finalPriceNegative((this.specMoney * Number(this.goodForm.count)),
						this
						.checked ? this.integral_type == 1 ? (parseFloat(this.goodForm.use_integral) <
							parseFloat(
								this.detailInfo.use_integral) ? this.goodForm.use_integral : this.detailInfo
							.use_integral) : Number(Math.round(this.specMoney * this.ratio) / 100).toFixed(2) :
						0
					)).toFixed(2)
				} else {
					use_integral = Number(this.finalPriceNegative((this.specMoney * Number(this.goodForm.count)),
						this
						.checked ? this.integral_type == 1 ? (parseFloat(this.goodForm.use_integral) <
							parseFloat(
								this.detailInfo.use_integral_partner) ? this.goodForm.use_integral : this
							.detailInfo
							.use_integral_partner) : Number(Math.round(this.specMoney * this.ratio) / 100)
						.toFixed(2) :
						0
					)).toFixed(2)
				}

				// use_integral = Number(this.finalPriceNegative((this.specMoney * Number(this.goodForm.count)),
				// 	this
				// 	.checked ? this.integral_type == 1 ? (parseFloat(this.goodForm.use_integral) <
				// 		parseFloat(
				// 			this.detailInfo.use_integral) ? this.goodForm.use_integral : this.detailInfo
				// 		.use_integral) : Number(Math.round(this.specMoney * this.ratio) / 100).toFixed(2) :
				// 	0
				// )).toFixed(2)

				console.log(this.checked ? use_integral : '')
				const {
					order_id,
					seckill_id,
					...newGoodForm
				} = this.goodForm;

				// if (this.detailInfo.order_status == 1) {
				// 	this.payPrice = Number(this.finalPrice(((Number(this.specMoney) + Number(0)) * Number(this.goodForm
				// 			.count)), this.goodForm
				// 		.use_integral)).toFixed(2) ? Number(this.finalPrice(((Number(this.specMoney) + Number(0)) *
				// 		Number(this
				// 			.goodForm
				// 			.count)), this.checked ? this.integral_type == 2 ? Number((Number(this
				// 				.specMoney) +
				// 			Number(0)) *
				// 		(this.ratio / 100)).toFixed(2) : this.goodForm.use_integral : 0)).toFixed(2) : '0.00'
				// } else {
				// 	this.payPrice = Number(this.finalPrice((this.specMoney * Number(this.goodForm.count)), this
				// 		.goodForm
				// 		.use_integral)).toFixed(2) ? Number(this.finalPrice((this.specMoney * Number(this.goodForm
				// 		.count)), this.checked ? this.integral_type == 2 ? Number(this.specMoney *
				// 		(this.ratio / 100)).toFixed(2) : this.goodForm.use_integral : 0)).toFixed(2) : '0.00'
				// }

				if (this.userInfosObj.is_partner == 0) {
					this.payPrice = Number(this.finalPrice((this.specMoney * Number(this.goodForm.count)), this
						.goodForm
						.use_integral)).toFixed(2) ? Number(this.finalPrice((this.specMoney * Number(this.goodForm
						.count)), this.checked ? this.integral_type == 2 ? Number(this.specMoney *
						(this.ratio / 100)).toFixed(2) : this.goodForm.use_integral : 0)).toFixed(2) : '0.00'
				} else {
					this.payPrice = Number(this.finalPrice((this.specMoney * Number(this.goodForm.count)), this
						.goodForm
						.use_integral)).toFixed(2) ? Number(this.finalPrice((this.specMoney * Number(this.goodForm
						.count)), this.checked ? this.integral_type == 2 ? Number(this.specMoney *
						(this.ratio / 100)).toFixed(2) : this.goodForm.use_integral : 0)).toFixed(2) : '0.00'
				}
				// this.payPrice = Number(this.finalPrice((this.specMoney * Number(this.goodForm.count)), this
				// 	.goodForm
				// 	.use_integral)).toFixed(2) ? Number(this.finalPrice((this.specMoney * Number(this.goodForm
				// 	.count)), this.checked ? this.integral_type == 2 ? Number(this.specMoney *
				// 	(this.ratio / 100)).toFixed(2) : this.goodForm.use_integral : 0)).toFixed(2) : '0.00'




				console.log(newGoodForm, (this.payPrice), use_integral)

				const result = await this.$http.post({
					url: this.$api.seckillSeckillPay,
					data: {

						use_integral: this.checked ? Number(use_integral) : '0',


						uid: uni.getStorageSync('uid'),
						// 产品id
						seckill_id: this.detailInfo.id,


						// 备注
						remark: newGoodForm.remark,

						// 是否需要开发票 1.不需要 2 需要
						need_invoice: newGoodForm.need_invoice,
						// 联系人
						contacts: newGoodForm.contacts,

					}
				});
				if (result.errno == 0) {
					this.itemAll = result.data;
					console.log(this.itemAll)

					this.applyOrder(this.itemAll);
				} else {
					this.$sun.toast(result.message);
					antiThrottling.releaseKey('submit');
				}
			},


			// 支付团购余款
			async groupPayOrder() {
				let use_integral
				// (Number(this.specMoney) + Number(this.detailInfo	.order_integral ? this.detailInfo.order_integral : 0))
				if (this.userInfosObj.is_partner == 0) {
					if (this.detailInfo.order_status == 1) {
						// 计算积分实付款
						use_integral = Number(this.finalPriceNegative(((Number(this.specMoney) + Number(0)) * Number(
								this
								.goodForm
								.count)),
							this
							.checked ? this.integral_type == 1 ? (parseFloat(this.goodForm.use_integral) <
								parseFloat(
									this.detailInfo.use_integral) ? this.goodForm.use_integral : this
								.detailInfo
								.use_integral) : Number(Math.round((Number(this.specMoney) + Number(0)) * this
								.ratio) / 100)
							.toFixed(2) :
							0
						)).toFixed(2)
					} else {
						// 计算积分实付款
						use_integral = Number(this.finalPriceNegative(((Number(this.specMoney) + Number(0)) * Number(
								this
								.goodForm
								.count)),
							this
							.checked ? this.integral_type == 1 ? (parseFloat(this.goodForm.use_integral) <
								parseFloat(
									this.detailInfo.use_integral) ? this.goodForm.use_integral : this
								.detailInfo
								.use_integral) : Number(Math.round((Number(this.specMoney) + Number(0)) * this
								.ratio) / 100)
							.toFixed(2) :
							0
						)).toFixed(2)
					}

				} else {
					if (this.detailInfo.order_status == 1) {
						// 计算积分实付款
						use_integral = Number(this.finalPriceNegative(((Number(this.specMoney) + Number(0)) * Number(
								this
								.goodForm
								.count)),
							this
							.checked ? this.integral_type == 1 ? (parseFloat(this.goodForm
									.use_integral) <
								parseFloat(
									this.detailInfo.use_integral_partner) ? this.goodForm.use_integral : this
								.detailInfo
								.use_integral_partner) : Number(Math.round((Number(this.specMoney) + Number(
									0)) * this
								.ratio) / 100)
							.toFixed(2) :
							0
						)).toFixed(2)
					} else {
						// 计算积分实付款
						use_integral = Number(this.finalPriceNegative(((Number(this.specMoney) + Number(0)) * Number(
								this
								.goodForm
								.count)),
							this
							.checked ? this.integral_type == 1 ? (parseFloat(this.goodForm
									.use_integral) <
								parseFloat(
									this.detailInfo.use_integral_partner) ? this.goodForm.use_integral : this
								.detailInfo
								.use_integral_partner) : Number(Math.round((Number(this.specMoney) + Number(
									0)) * this
								.ratio) / 100)
							.toFixed(2) :
							0
						)).toFixed(2)
					}

				}

				console.log(this.checked ? use_integral : '')
				const {
					order_id,
					seckill_id,
					...newGoodForm
				} = this.goodForm;

				// (Number(this.specMoney) + Number(this.detailInfo	.order_integral ? this.detailInfo.order_integral : 0))
				if (this.userInfosObj.is_partner == 0) {
					if (this.detailInfo.order_status == 1) {
						this.payPrice = Number(this.finalPrice(((Number(this.specMoney) + Number(0)) * Number(this
								.goodForm
								.count)), this.goodForm
							.use_integral)).toFixed(2) ? Number(this.finalPrice(((Number(this.specMoney) + Number(
								0)) *
							Number(this
								.goodForm
								.count)), this.checked ? this.integral_type == 2 ? Number((Number(this
									.specMoney) +
								Number(0)) *
							(this.ratio / 100)).toFixed(2) : this.goodForm.use_integral : 0)).toFixed(2) : '0.00'


					} else {
						this.payPrice = Number(this.finalPrice((this.specMoney * Number(this.goodForm.count)), this
							.goodForm
							.use_integral)).toFixed(2) ? Number(this.finalPrice((this.specMoney * Number(this
							.goodForm
							.count)), this.checked ? this.integral_type == 2 ? Number(this.specMoney *
							(this.ratio / 100)).toFixed(2) : this.goodForm.use_integral : 0)).toFixed(2) : '0.00'

					}
				} else {
					if (this.detailInfo.order_status == 1) {
						this.payPrice = Number(this.finalPrice(((Number(this.specMoney) + Number(0)) * Number(this
								.goodForm
								.count)), this.goodForm
							.use_integral)).toFixed(2) ? Number(this.finalPrice(((Number(this.specMoney) + Number(
								0)) *
							Number(this
								.goodForm
								.count)), this.checked ? this.integral_type == 2 ? Number((Number(
									this
									.specMoney) +
								Number(0)) *
							(this.ratio / 100)).toFixed(2) : this.goodForm.use_integral : 0)).toFixed(2) : '0.00'


					} else {
						this.payPrice = Number(this.finalPrice((this.specMoney * Number(this.goodForm.count)), this
							.goodForm
							.use_integral)).toFixed(2) ? Number(this.finalPrice((this.specMoney * Number(this
							.goodForm
							.count)), this.checked ? this.integral_type == 2 ? Number(this
							.specMoney *
							(this.ratio / 100)).toFixed(2) : this.goodForm.use_integral : 0)).toFixed(2) : '0.00'

					}
				}

				console.log(newGoodForm, (this.payPrice), this.checked ? Number(use_integral) : this.detailInfo
					.order_status == 1 ?
					(this.detailInfo.order_integral ? this.detailInfo.order_integral : '0') : '0', )


				const result = await this.$http.post({
					url: this.$api.grouponBuy,
					data: {

						use_integral: this.checked ? Number(use_integral) : this.detailInfo.order_status == 1 ?
							(this.detailInfo.order_integral ? this.detailInfo.order_integral : '0') : '0',


						uid: uni.getStorageSync('uid'),
						// 产品id
						order_id: this.detailInfo.order_id,



						// 备注
						remark: newGoodForm.remark,

						// 是否需要开发票 1.不需要 2 需要
						need_invoice: newGoodForm.need_invoice,
						// 联系人
						contacts: newGoodForm.contacts,

					}
				});
				if (result.errno == 0) {
					this.itemAll = result.data;
					console.log(this.itemAll)

					this.applyOrder(this.itemAll);
				} else {
					this.$sun.toast(result.message);
					antiThrottling.releaseKey('submit');
				}
			},

			// 购买产品
			async addOrders() {
				// (Number(this.specMoney) + Number(this.detailInfo	.order_integral ? this.detailInfo.order_integral : 0))
				let use_integral
                console.log(this.userInfosObj.is_partner, this.integral_type,'=====',)

				if (this.userInfosObj.is_partner == 0) {
					if (this.detailInfo.order_status == 1) {

						// 计算积分实付款
						use_integral = Number(this.finalPriceNegative(((Number(this.specMoney) + Number(0)) * Number(
								this
								.goodForm
								.count)), this
							.checked ? this.integral_type == 1 ? (parseFloat(this.goodForm.use_integral) <
								parseFloat(
									this.detailInfo.use_integral) ? this.goodForm.use_integral : this
								.detailInfo
								.use_integral) : Number(Math.round(t(Number(this.specMoney) + Number(0)) * this
								.ratio) / 100).toFixed(2) : 0
						)).toFixed(2)
					} else {
						// 计算积分实付款
						use_integral = Number(this.finalPriceNegative((this.specMoney * Number(this.goodForm.count)),
							this
							.checked ? this.integral_type == 1 ? (parseFloat(this.goodForm.use_integral) <
								parseFloat(
									this.detailInfo.use_integral) ? this.goodForm.use_integral : this
								.detailInfo
								.use_integral) : Number(Math.round(this.specMoney * this.ratio) / 100).toFixed(
								2) :
							0
						)).toFixed(2)
					}

				} else {
					if (this.detailInfo.order_status == 1) {

						// 计算积分实付款
						use_integral = Number(this.finalPriceNegative(((Number(this.specMoney) + Number(0)) * Number(
								this
								.goodForm
								.count)), this
							.checked ? this.integral_type == 1 ? (parseFloat(this.goodForm.use_integral) <
								parseFloat(
									this.detailInfo.use_integral_partner) ? this.goodForm.use_integral : this
								.detailInfo
								.use_integral_partner) : Number(Math.round(t(Number(this.specMoney) + Number(
									0)) * this
								.ratio) / 100).toFixed(2) : 0
						)).toFixed(2)
					} else {
						// 计算积分实付款
						use_integral = Number(this.finalPriceNegative((this.specMoney * Number(this.goodForm.count)),
							this
							.checked ? this.integral_type == 1 ? (parseFloat(this.goodForm.use_integral) <
								parseFloat(
									this.detailInfo.use_integral_partner) ? this.goodForm.use_integral : this
								.detailInfo
								.use_integral_partner) : Number(Math.round(this.specMoney * this.ratio) / 100)
							.toFixed(2) :
							0
						)).toFixed(2)
					}

				}


				console.log(this.checked ? use_integral : '')
				const {
					order_id,
					seckill_id,
					...newGoodForm
				} = this.goodForm;
				if (this.userInfosObj.is_partner == 0) {
					// (Number(this.specMoney) + Number(this.detailInfo	.order_integral ? this.detailInfo.order_integral : 0))
					if (this.detailInfo.order_status == 1) {
						this.payPrice = Number(this.finalPrice(((Number(this.specMoney) + Number(0)) * Number(this
								.goodForm
								.count)), this
							.goodForm
							.use_integral)).toFixed(2) ? Number(this.finalPrice(((Number(this.specMoney) + Number(
								0)) *
							Number(this
								.goodForm
								.count)), this.checked ? this.integral_type == 2 ? Number((Number(this
									.specMoney) +
								Number(0)) *
							(this.ratio / 100)).toFixed(2) : this.goodForm.use_integral : 0)).toFixed(2) : '0.00'
					} else {
						this.payPrice = Number(this.finalPrice((this.specMoney * Number(this.goodForm.count)), this
							.goodForm
							.use_integral)).toFixed(2) ? Number(this.finalPrice((this.specMoney * Number(this
							.goodForm
							.count)), this.checked ? this.integral_type == 2 ? Number(this.specMoney *
							(this.ratio / 100)).toFixed(2) : this.goodForm.use_integral : 0)).toFixed(2) : '0.00'
					}

				} else {
					// (Number(this.specMoney) + Number(this.detailInfo	.order_integral ? this.detailInfo.order_integral : 0))
					if (this.detailInfo.order_status == 1) {
						this.payPrice = Number(this.finalPrice(((Number(this.specMoney) + Number(0)) * Number(this
								.goodForm
								.count)), this
							.goodForm
							.use_integral)).toFixed(2) ? Number(this.finalPrice(((Number(this.specMoney) + Number(
								0)) *
							Number(this
								.goodForm
								.count)), this.checked ? this.integral_type == 2 ? Number((Number(this
									.specMoney) +
								Number(0)) *
							(this.ratio / 100)).toFixed(2) : this.goodForm.use_integral : 0)).toFixed(2) : '0.00'
					} else {
						this.payPrice = Number(this.finalPrice((this.specMoney * Number(this.goodForm.count)), this
							.goodForm
							.use_integral)).toFixed(2) ? Number(this.finalPrice((this.specMoney * Number(this
							.goodForm
							.count)), this.checked ? this.integral_type == 2 ? Number(this.specMoney *
							(this.ratio / 100)).toFixed(2) : this.goodForm.use_integral : 0)).toFixed(2) : '0.00'
					}

				}


				console.log(newGoodForm, (this.payPrice), use_integral)

				const result = await this.$http.post({
					url: this.$api.orderAdd,
					data: {

						use_integral: this.checked ? Number(use_integral) : '0',


						uid: uni.getStorageSync('uid'),
						// 产品id
						goods_id: this.detailInfo.id,


						// 规格id
						spec_id: newGoodForm.spec_id ? newGoodForm.spec_id : '',

						// 商品数量
						count: this.goodForm.count,

						// 备注
						remark: newGoodForm.remark,

						// 是否需要开发票 1.不需要 2 需要
						need_invoice: newGoodForm.need_invoice,
						// 联系人
						contacts: newGoodForm.contacts,

					}
				});
				if (result.errno == 0) {
					this.itemAll = result.data;
					console.log(this.itemAll)

					this.applyOrder(this.itemAll);
				} else {
					this.$sun.toast(result.message);
				   antiThrottling.releaseKey('submit');
				}
				
			},
			// 生成订单后——支付
			applyOrder(number) {
				this.pays(this.itemAll);
			},
			// 支付
			async pays(item) {
				const result = await this.$http.get({
					url: this.$api.wxPay,
					data: {

						// 支付金额
						price: this.payPrice,
						// 订单编号
						log_no: item,
						// opid
						openid: wx.getStorageSync('user').openid,

						name: this.detailInfo.name ? this.detailInfo.name : this.detailInfo.goods_name
					}
				});
				if (result.errno == 0) {
					this.$sun.title('支付');
					const pay = result.data;
					this.$sun.wePay(
						pay,
						async success => {
								// 防止二次付款没有抵扣金


								// uni.setStorageSync('use_integral', use_integral);
								antiThrottling.releaseKey('submit');
								// false 普通商品 true团购商品
								if (this.activitType == 0) {
									this.$sun.navRe('/pages/orderMessage/goodsOrderList/goodsOrderList', {

										tabOrder: 3
									});
								} else if (this.activitType == 1) {
									this.$sun.navRe('/pages/orderMessage/orderList/orderList', {
										tabSwitchOrder: 0,
										tabOrder: 4
									});
								} else if (this.activitType == 2) {
									this.$sun.navRe('/pages/orderMessage/orderList/orderList', {
										tabSwitchOrder: 1,
										tabOrder: 3
									});
								} else if (this.activitType == 3) {
									this.$sun.navRe('/pages/orderMessage/orderList/orderList', {
										tabSwitchOrder: 2,
										tabOrder: 4
									});
								} else if (this.activitType == 4) {
									this.$sun.navRe('/pages/orderMessage/orderList/orderList', {
										tabSwitchOrder: 3,
										tabOrder: 4
									});
								}


							},
							async cancel => {
								this.$sun.toast('取消了支付');
								antiThrottling.releaseKey('submit');
								// false 普通商品 true团购商品
								if (this.activitType == 0) {
									this.$sun.navRe('/pages/orderMessage/goodsOrderList/goodsOrderList', {

										tabOrder: 2
									});
								} else if (this.activitType == 1) {
									this.$sun.navRe('/pages/orderMessage/orderList/orderList', {
										tabSwitchOrder: 0,
										tabOrder: 2
									});
								} else if (this.activitType == 2) {
									this.$sun.navRe('/pages/orderMessage/orderList/orderList', {
										tabSwitchOrder: 1,
										tabOrder: 2
									});
								} else if (this.activitType == 3) {
									this.$sun.navRe('/pages/orderMessage/orderList/orderList', {
										tabSwitchOrder: 2,
										tabOrder: 2
									});
								} else if (this.activitType == 4) {
									this.$sun.navRe('/pages/orderMessage/orderList/orderList', {
										tabSwitchOrder: 3,
										tabOrder: 2
									});
								}
							}
					);
				} else {
					this.$sun.toast(result.message);
					antiThrottling.releaseKey('submit');
				}
			},
			// 余额支付
			async balancePays(item) {
				const result = await this.$http.post({
					url: this.$api.balancePay,
					data: {
						uid: uni.getStorageSync('uid'),
						// 订单id
						order_id: item.order_id
					}
				});
				if (result.code == 0) {
					// false 普通商品 true团购商品
					if (this.isGroupShop == false) {
						this.$sun.navRe('/pages/orderMessage/orderMessage', {
							id: 1
						});
					} else {
						this.$sun.navRe('/pages/orderMessage/groupOrder/groupOrder', {
							id: 1
						});
					}
				} else {
					this.$sun.toast(result.message);
				}
			}
		}
	};
</script>

<style lang="less">
	// 购物车进入css
	.v-shop-cart {
		padding: 34rpx;
		border-bottom: 2rpx solid #f7f7f7;

		image {
			width: 140rpx;
			height: 140rpx;
			margin-right: 26rpx;
		}



		.v-content {
			height: 140rpx;
			position: relative;

			.v-name {
				font-size: 32rpx;
				font-weight: bold;
			}

			.v-spec {
				width: 400rpx;
			}

			text {
				color: #8f8f8f;
				// padding: 10rpx 0;
				padding: 10rpx 0 16rpx;
			}

			.v-price {
				position: absolute;
				bottom: 0;
				color: #ff5f4e;
				font-size: 34rpx;
			}

		}
	}

	.deductionFeeImg {
		width: 40rpx;
		height: 40rpx;
		margin-right: 10rpx;
	}

	.v-confirm-order {
		.v-padding {
			.rightImg {
				width: 17rpx;
				height: 27.92rpx;
			}

			padding: 0 38rpx 42rpx 34rpx;
			background-color: #fff;

			.v-color {
				color: #ff5f4e;
				padding-top: 54rpx;
			}

			.v-top {
				padding-top: 54rpx;
			}

			.v-p-top {
				margin-top: 34rpx;
				color: #8f8f8f;
			}

			.v-content {
				padding-top: 48rpx;

				view {
					color: #8f8f8f;
				}

				input {
					text-align: right;
				}

				.v-integral {
					color: #fe9a31;
					margin-right: 14rpx;
				}

				.apply-radio {
					margin-left: 20rpx;

					radio {
						transform: scale(0.8);
					}
				}
			}
		}

		.purchaseGoods {
			margin: 0 55rpx 20rpx;
			height: 108rpx;
			border-radius: 40rpx;

			background: rgb(0, 149, 255);
		}

		// 使用优惠券
		.v-pop-coupon {
			background: #ffffff;
			border-radius: 20rpx 20rpx 0 0;
			padding: 42rpx 0 0;

			.v-coupon-tilte {
				font-size: 32rpx;
				font-weight: bold;
				padding-bottom: 32rpx;
			}

			.v-discount {
				font-size: 32rpx;
				padding: 0 24rpx 30rpx;
			}

			.v-coupons {
				height: 160rpx;
				margin: 0 24rpx 20rpx;
				background-color: #f1f5ff;

				// background: #fcfdff;
				.v-left {
					.v-coupon-price {
						width: 140rpx;
						color: #294d7d;
						font-size: 36rpx;
						font-weight: bold;
						padding: 0 32rpx;
					}

					.v-identification {
						font-size: 24rpx;
						margin-top: 10rpx;
						color: #bdbbbb;
					}

					.v-conditions-met {
						border-left: 2rpx dashed #c9caca;
						padding: 0 34rpx;

						text {
							color: #a1a1a1;
							font-size: 24rpx;
							padding: 6rpx;
						}
					}
				}

				.v-coupon-btn {
					background: #294d7d;
					color: #ffffff;
					min-width: 150rpx;
					padding: 60rpx 0;
					font-size: 32rpx;
				}
			}

			.v-coupon-close {
				font-size: 32rpx;
				background: #294d7d;
				color: #ffffff;
				border-radius: 90rpx;
				// margin-top: 20rpx;
				width: 648rpx;
				height: 96rpx;
			}
		}
	}

	/* 隐私协议 start */
	.radioText {
		margin: 38rpx 0;
	}

	.agree {
		color: #666;

		text {
			color: #1890ff;
			// color: #19c866;
		}
	}

	.animation {
		width: 10rem;
		height: 2rem;
		background: #ffffff;
		margin-top: 0.5rem;
	}

	.animation-shake {
		animation: shake 0.3s !important;
	}

	@keyframes shake {

		0%,
		100% {
			transform: translateX(0);
		}

		10% {
			transform: translateX(-18rpx);
		}

		20% {
			transform: translateX(16rpx);
		}

		30% {
			transform: translateX(-14rpx);
		}

		40% {
			transform: translateX(12rpx);
		}

		50% {
			transform: translateX(-10rpx);
		}

		60% {
			transform: translateX(8rpx);
		}

		70% {
			transform: translateX(-6rpx);
		}

		80% {
			transform: translateX(4rpx);
		}

		90% {
			transform: translateX(-2rpx);
		}
	}

	/* 隐私协议 end */
</style>